package com.markus.code.exam.xiecheng;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

/**
 * Author:markusZhang
 * Date:Create in 2020/8/15 18:57
 * todo:
 */
public class Main {
    static int[] divingBoard(int a, int b, int k) {
        if (k == 0){
            return new int[0];
        }
        List<Integer> resList = new ArrayList<>();
        HashSet<Integer> hashSet = new HashSet<>();
        for (int i=0;i<=k;i++){
            int ansA = i * a;
            int ansB = (k-i) * b;
            int ans = ansA + ansB;
            if (!hashSet.contains(ans)){
                resList.add(ans);
                hashSet.add(ans);
            }
        }
        int res[] = new int[resList.size()];
        int i = 0;
        for (Integer integer : resList) {
            res[i++] = integer;
        }
        Arrays.sort(res);
        return res;
    }

    public static void main(String[] args) {
        int[] ints = divingBoard(1, 2, 0);
        for (int anInt : ints) {
            System.out.print(anInt+" ");
        }
    }
}
